Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@talend/module-to-cdn
Advanced tools
Get cdn config from npm module name
This module is fork of module-to-cdn from Thomas Sileghem.
Because unpkg is great for free usage but not for production usage we decided to made some changes to going forward.
After big PR on the repository and an email to the author we have got no news as all other PRs. So we decided to fork.
$ npm install --save @talend/module-to-cdn
const moduleToCdn = require('@talend/module-to-cdn');
moduleToCdn('react', '15.3.0');
/* => {
name: 'react',
var: 'React',
url: 'https://unpkg.com/react@15.3.0/dist/react.min.js',
version: '15.3.0',
path: '/dist/react.min.js',
local: '/Users/me/module-to-cdn/node_modules/react/dist/react.min.js'
}
*/
Note if the package comes with css you will have them under styleUrl
and stylePath
properties
return the result Object
or null (if module couldn't be find)
Type: string
The name of the module
Type: string
The version of the module
Type: string
Values: development
, production
Default: development
name
: name of the modulevar
: name of the global variable exposing the moduleurl
: url where the module is availableversion
: the version asked forpath
: relative path of the umd file in the distributed packagelocal
: absolute path on the current system to the fileBy default the URL resolver just resolve to unpkg. You can change that using the following API.
import moduleToCdn from '@talend/module-to-cdn';
function myResolver(...args) {
const info = moduleToCdn(...args);
if (process.env.NODE_ENV !== 'development') {
return {
...info,
url: `https://cdn.talend.com/${info.name}/${info.version}${info.path}`
};
}
return info;
}
moduleToCdn.configure(myResolver);
The module.json file is an open effort on existing opensource libs. If you want to support custom internal library you can add entries in this file using the following API:
import moduleToCdn from '@talend/module-to-cdn';
moduleToCdn.add({
'@talend/my-private-module': {
var: 'TalendMyPrivateModule',
versions: {
'>= 0.0.0': {
development: '/dist/build.js',
production: '/dist/build.min.js'
}
}
}
});
This will affect all future call to moduleToCdn;
This module do integration tests so it requests npm / unpkg for every packages on the limit of each version and also it tries to fetch the @next version to be as future proof as possible
So if you want to focus on a given module you can use the LIMIT env variable
LIMIT=";ag-grid;ag-grid-community;ag-grid-enterprise;" ava -v
For the sake of simplicity, range must match between js and styles. Here is the line in the code that read it:
const styleConfig = moduleConf['style-versions'] && moduleConf['style-versions'][range];
So take it as a constraint, for example:
"@talend/design-tokens": {
"var": "TalendDesignTokens",
"versions": {
"> 2.6.0": {
"development": "/dist/TalendDesignTokens.js",
"production": "/dist/TalendDesignTokens.min.js"
}
},
"style-versions": {
"> 2.6.0": {
"development": "/dist/TalendDesignTokens.css",
"production": "/dist/TalendDesignTokens.min.css"
}
}
}
To add your modules you have to
Example of not valid umd: https://unpkg.com/browse/react-popper@1.3.7/dist/index.umd.js createContext,deepEqual dependencies are always null.
MIT © Thomas Sileghem
FAQs
Get cdn config from npm module name
The npm package @talend/module-to-cdn receives a total of 416 weekly downloads. As such, @talend/module-to-cdn popularity was classified as not popular.
We found that @talend/module-to-cdn demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.